package com.itheima.HomeWork.Exer;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Demo02 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"张无忌,15","周芷若,14","赵敏,13","张强,20","张三丰,100","张翠山,40","张良,35");
         /*list.stream().map(new Function<String, Student>() {
             @Override
             public Student apply(String s) {
                 return new Student(s.split(",")[0],Integer.parseInt(s.split(",")[1]));
             }
         }).forEach(student -> System.out.println(student));*/
//        list.stream().map(s -> new Student(s.split(",")[0],Integer.parseInt(s.split(",")[1]))).forEach(student -> System.out.println(student));
        List<Student> collect = list.stream().map(Student::new).collect(Collectors.toList());
        System.out.println(collect);
    }
}
